﻿<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>班牌机</title>
	<link rel="stylesheet" href="/css/common2.css">
	<style>
		.school {
			margin-left: 2%;
			margin-top: 20px;
			display: inline-block;
		}

		.search_img,
		.add {
			margin-left: 2%;
			margin-top: 0;
			display: inline-block;
		}
	</style>
</head>

<body class="main-body">
	<div id="vue-root" style="margin-top: 50px;">
		<div>
			<div class="add" v-if="able.add">
				<a href="board_item.html" style="color: white">添加班牌机</a>
			</div>
			<div class="refresh" onclick="location.reload()" style="margin-left: 0;">刷新</div>
			<div class="school">
				<select name="drop1" class="search" v-model="search.classesId"
					style="position: absolute; right: 255px; margin-top: -28px;">
					<option :value="undefined">请选择班级</option>
					<option v-for="classes in classess" :key="classes.id" :value="classes.id" v-text="classes.name">
					</option>
				</select>
			</div>
			<input class="search" placeholder="请输入设备号码" v-model="search.code"
				style="position: absolute; right: 100px; margin-top: -5px; height: 33px; max-width: 120px;">

			<img src="/image/search.png" alt="" class="search_img" @click="getData0" height="35" width="35"
				style="position: absolute; right: 3%; margin-top: -5px;">
			<div class="table ">
				<table class="table_top">
					<thead>
						<tr>
							<th class="one">
								<input type="checkbox" class="check-box" v-model="all">序号
							</th>

							<th class="four">班级名称</th>
							<th class="four">设备名称</th>
							<th class="four">设备号</th>
							<th>刷新数据</th>
							<th class="three" v-if="able.edit||able.del">编辑/删除</th>
						</tr>
					</thead>
					<tbody id="list">
						<tr v-for="(board,index) in list" :key="board.id">
							<td>
								<input type="checkbox" class="check-box" v-model="board.checked">
								<span v-text="index+1"></span>
							</td>
							<td class="four" v-text="board.classesName"></td>
							<td class="four" v-text="board.name"></td>
							<td class="text" v-text="board.code"></td>
							<td>
								<button @click="refresh(board.code)">刷新数据</button>
							</td>
							<td class="three" v-if="able.edit||able.del">
								<div class="option">
									<div v-if="able.edit" class="edit-icon option-icon">
										<a :href="'board_item.html?id='+board.id"
											style="position: absolute; left: 20%; top: 30%;">
											<img class="img" src="/image/edit.png" height="20" width="20"
												onmouseover="this.src='/image/edit_light.png'"
												onmouseout="this.src='/image/edit.png'" />
										</a>
									</div>
									<div v-if="able.del" class="delete-icon option-icon" @click="del([board.id])"
										style="right: 20%; top:30%;position: absolute;">
										<img class="img" src="/image/delete.png" height="20" width="20"
											onmouseover="this.src='/image/delete_light.png'"
											onmouseout="this.src='/image/delete.png'" />
									</div>
								</div>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>

		<div class="delete" @click="batchDelete" v-if="able.del||total>1">批量删除</div>

		<ul class="pagination" v-if="pages>1">
			<li>
				<a v-if="pageNum!=1" @click="pageNum=1">«</a>
				<a class="pages-jump" v-if="pageNum!=1" @click="pageNum--">‹</a>
				<a v-text="pageNum"></a>
				<a class="pages-jump" v-if="pageNum!=pages" @click="pageNum++">›</a>
				<a v-if="pageNum!=pages" @click="pageNum=pages">»</a>
			</li>
		</ul>

	</div>


	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>

	<script src="/scriptZIP/dayjs.min.js"></script>

	<script src="/scriptZIP/dayjs.min.js"></script>


	<script src="/js/common.js"></script>
	<script src="/js/list.js"></script>
	<script src="/js/auth_util.js"></script>

	<script>

		var app = new Vue(merge({
			data: {
				classess: [],
				search: {
					schoolId: top_params().id,
				},
				urls: {
					list: '/pc/board/list',
					del: '/pc/board/del'
				}
			},
			created: function () {
				this.getData();

				axios.get('/pc/classes/all/' + this.search.schoolId).then(function (res) {
					this.classess = res.data;
				}.bind(this));
				abled('board', this);
			},
			methods: {
				format: function (time) {
					if (!time) return '';
					return dayjs(time).format('YYYY-MM-DD HH:mm:ss');
				},
				refresh: function (code) {
					axios.post('/pc/device/refresh', toFormParams({ code: code })).then(function (res) {
						if (res.data) alert('已发送请求');
						else alert('设备未连接。请检查设备网络连接');
					});
				},
			}
		}));
	</script>


</body>

</html>